<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.js"></script>
</head>

<body>
    <div id="app">
        <h2>总分：{{sum}}</h2>
        <h2>总分：{{sum}}</h2>
        <h2>总分：{{sum}}</h2>
        <ul>
            <li v-for="(item,index) in scores">{{index+1}}、{{item}}</li>
        </ul>
    </div>

    <script>
        new Vue({
            el: '#app',
            data: {
                scores:[100,20,30,40,50,60,70,80,90,100]
            },
            computed: {
                sum:{
                    get(){
                        console.log("计算总分");
                        var sum =0;
                        this.scores.forEach(element => {
                                sum+=element;
                        });
                        return sum;
                    },
                    set(value){

                    }
                }
            },
            methods: {
                
            },
        })
    </script>
</body>

</html>